<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>商品库管理后台</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/css/commom.css" />
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/css/main.css" />
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/css/shangjiaAdmin.css" />
<script src="<{$siteurl}>/templates/<{$tempdir}>/public/js/jquery.js" type="text/javascript" language="javascript"></script>
<script src="<{$siteurl}>/templates/<{$tempdir}>/public/js/allj.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/artdialog/artDialog.js?skin=blue"></script> 
<script src="<{$siteurl}>/templates/<{$tempdir}>/public/js/artdialog/plugins/iframeTools.js" type="text/javascript" language="javascript"></script>
<script> 
	var siteurl = "<{$siteurl}>"; 
</script>
</head>
<body>
	<div style="position: fixed;top: 0;left: 0;right: 0;bottom: 0;z-index: -1;background:url(<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/images/background.png);"></div>
<!---header start--->
<div class="header" style=" height:50px;">
  <div class="top" style=" height:50px;">
   
   
    <div class="topRight fr">  <span style=" height:50px; line-height:50px;cursor: pointer;" class="username" onclick="openlink('<{ofunc type=url link="/adminpage/order/module/orderlist"}>');">返回后台管理<img src="<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/images/usernameBg.png" /></span> </div>
    <div class="cl"></div>
    <div class="shangjiaTop" style=" top:-22px; margin-left:-150px;">
      <div class="sjglaa" style="background: rgba(0, 0, 0, 0) url(<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/images/goodslibtopbg.png) no-repeat scroll 0 0;"> </div>
    </div>
  </div>
</div>

<!---header end---> 
	

<div class="content">

    <script src="<{$siteurl}>/templates/<{$tempdir}>/public/shopcenter/js/notRefreshFilesUpload.js"></script>
    <script>
        $(function () {

            var btn = $("#Button1");

            btn.uploadFile({
                url: "WebForm1.aspx",
                fileSuffixs: ["jpg", "png", "gif"],
                buttonFeature: true,
                errorText: "{0}",
                maximumFilesUpload: 5,//最大文件上传数
                onComplete: function (msg) {
                    $("#testdiv").html(msg);
                },
                perviewImageElementId: "fileList", //设置预览图片的元素id
                perviewImgStyle: { width: '100px', height: '100px', border: '1px solid #ebebeb' }//设置预览图片的样式
            });

            var upload = btn.data("uploadFileData");

            $("#files").click(function () {
                upload.submitUpload();
            });
        });
    </script>


        
        
        <div style="width: 400px; height: 300px; float:left">
            <input id="Button1" type="button" value="选择文件" />
            <input id="files" type="button" value="上传" />
            <div id="fileList" style="margin-top: 10px; padding-top:10px; border-top:1px solid #C0C0C0;font-size: 13px; width:400px">
                
            </div>
        </div>
        <div id="testdiv"></div>
    
 
 </div>
 
 
	

 
 
 <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/artdialog/plugins/iframeTools.js"></script>
<script>
$(function(){
//删除分类
var checkisexti =  $('.caidanTitle').find('li').length;
if(checkisexti == 0){
 
  $('.caidanSet').hide();
}
$('.delGDtype').live('click',function(){
	if(confirm('确定删除商品操作吗？删除后将同时删除该分类下的所有商品')){ 
		var allobj = $(".caidanSet").find('li');
		var typeid = 0;
		for(var i=0;i< $(allobj).length;i++){ 
		   if($(allobj).eq(i).hasClass("cur") ==  true){
		      typeid = $(allobj).eq(i).attr('data');
		    }
		}
		 
    myajax('<{ofunc type=url link="/adminpage/shop/module/delgoodstype/datatype/json"}>',{'addressid':typeid});
  }
});	
//编辑分类
$('.editGDtype').live('click',function(){
	var allobj = $(".caidanSet").find('li');
		var typeid = 0;
		var typename = '';
		var typeorder = '';
		for(var i=0;i< $(allobj).length;i++){ 
		   if($(allobj).eq(i).hasClass("cur") ==  true){
		      typeid = $(allobj).eq(i).attr('data');
		      typename = $(allobj).eq(i).attr('dataname');
		      typeorder = $(allobj).eq(i).attr('dataorder');
		    }
		}
	var	htmls = '<form method="post" id="doshwoform" action="#" style="text-align:center;"><table>';
	htmls += '<tbody><tr>';
	htmls += '<td height="50px">分类名称:</td>';
	htmls += '<td> <input type="text" name="newtypename" value="'+typename+'" style="width:100px;"></td></tr>';
	htmls +='<tr><td height="50px">排序ID:</td><td style="text-align:left;"> <input type="text" name="newtypeorderid" value="'+typeorder+'" style="width:50px;"></td></tr>'
	htmls += '</tbody></table> ';
  htmls += '<input type="hidden" value="'+typeid+'" name="newtypeid"> ';
	htmls += '<input type="button" value="确认提交" class="button" id="updategoodstype" ></form>';
  art.dialog({
    id: 'testID3',
    title:'保存店铺分类',
    content: htmls
  });
	
	
});
//保持编辑分类
$('#updategoodstype').live('click',function(){
 
	  showop('保存商品分类信息');
	   myajax('<{ofunc type=url link="/adminpage/shop/module/editgoodstype/datatype/json"}>',{'what':'allinfo','name':$('input[name="newtypename"]').val(),'orderid':$('input[name="newtypeorderid"]').val(),'addressid':$('input[name="newtypeid"]').val()}); 
});
	
//添加商品分类
$("#add_FoodType").live("click", function() {   
	if($('#shoptypename').val() == ''||$('#shoptypename').val() ==null){
		diaerror('分类不能空'); 
	}else{
		var mm = $('#shoptypename').val();
		$('#shoptypename').val('')
	   myajax('<{ofunc type=url link="/adminpage/shop/module/savegoodstype/datatype/json"}>',{'name':mm,'orderid':$(".caidanSet").find('li').length}); 
  }
});


//导航条切换	
$(".caidanSet ul li").click(function(){
						$(this).addClass('cur').siblings().removeClass('cur');
					   var tempid = $(this).attr('data');
					   $('.listgoodsdet').hide();
					  $('.goodsdiv_'+tempid).show();
					  $('input[name="adgoodstypeid"]').val(tempid);
					  $('#additem').hide();
					  //获取坐标
				//
				var fleft = $('.caidanSet').offset().left;
				var zleft = $(this).offset().left;
				var resulte = Number(zleft) -Number(fleft);
				$('#editGtype').css('margin-left',resulte);
			 
					  
						
});	
$(".caidanSet").find("li").eq(0).trigger("click");//设置默认第一个
					
//快捷编辑商品					
$(".listgoodsdet p").live("click", function() {  
	var is_save = $(this).hasClass('now_edit');
	var typename = $(this).attr('class');
	var doc = $(this).text();
	 if(is_save){
	 	 
	 }else{
	 	$(this).addClass('now_edit');
	 	var goodsid = $(this).parent().parent().parent().attr('data');
	 	 
	 	 $(this).html('<input style="width:45%;" type="text" value="'+doc+'" id="'+typename+goodsid+'" \/> <span class="curbtn" onclick="savegoodtxt(\''+goodsid+'\',\''+typename+'\');">保存<\/span>');
	 } 
});

//显示添加商品
$('#addgoods').live('click',function(){
	$('#additem').show();
});
//提交添加商品
$('#saveaddgoods').live('click',function(){
	var typeid =   $('input[name="adgoodstypeid"]').val(); 
	var data1 = $('input[name="adgoodname"]').val(); 
	var data2 = $('input[name="adgoodcost"]').val(); 
	var data5 = $('input[name="adgoodpaixu"]').val(); 
	if(typeid == ''){
	 alert('请选择商品类型');
	 return false;
	}
	if(data1 == ''){
	  alert('请录入商品名称');
	  return false;
	} 
		if(confirm('确定操作吗？')){ 
			 showop('保存商品信息');  
	    var backinfo = ajaxback('<{ofunc type=url link="/adminpage/shop/module/addgoods/datatype/json"}>',{'name':data1,'typeid':typeid,'cost':data2,'good_order':data5});
	    if(backinfo.flag == true)
	    {
		      hideop();
		     diaerror(backinfo.content); 
	     }else{
	  	    hideop(); 
	  	    var htmldata = '<div class="order_list	listgoodsdet goodsdiv_'+backinfo.content.typeid+'" data="'+backinfo.content.id+'" id="goodstr_'+backinfo.content.id+'" >';
              htmldata += ' <div class="order_goodlist">';
              htmldata += '       <div class="cd_name">';
              htmldata += '          <p class="name">'+backinfo.content.name+'</p>';
              htmldata += '       </div>';
              htmldata += '      <div class="cd_price">';
              htmldata += '          <p class="cost">'+backinfo.content.cost+'</p>  ';
              htmldata += '     </div>';
			    htmldata += '      <div class="cd_order">';
              htmldata += '           <p class="good_order">'+backinfo.content.good_order+'</p>   ';
              htmldata += '      </div>';
              htmldata += '       <div class="cd_caozuo">';
              htmldata += '          <span style=" background:#27a9e3; padding:8px; color:#fff;" class="curbtn" onclick="editgoods(\''+backinfo.content.id+'\');">编辑</span>';
              htmldata += '            <span style=" background:#ec7501; padding:8px; color:#fff;" class="curbtn" onclick="delgoods(\''+backinfo.content.id+'\');">删除</span>';
              htmldata += '      </div>';
              htmldata += '  </div> ';
              htmldata += '</div>'; 
          $('#additem').before(htmldata); 
          $('input[name="adgoodname"]').val(''); 
	           $('input[name="adgoodcost"]').val(''); 

	            $('#additem').hide();
	  	    artsucces('保存成功');
		     
	     } 
		}
	 
});
//删除商品



 		
});

function savegoodtxt(goodsid,typename){ 
  	var values = $('#'+typename+goodsid).val();
	   showop('保存商品信息');
	  var backinfo = ajaxback('<{ofunc type=url link="/adminpage/shop/module/updategoods/datatype/json"}>',{'controlname':typename,'goodsid':goodsid,'values':values});
	  if(backinfo.flag == true)
	  {
		  hideop();
		  diaerror(backinfo.content); 
	  }else{
	  	 hideop();
	  	 $('#goodstr_'+goodsid).find('.'+typename).text(values);
	  	 $('#goodstr_'+goodsid).find('.'+typename).removeClass('now_edit');
	  	 artsucces('保存成功');  
	 } 
}

function delgoods(gid){
   if(confirm('确定删除该商品操作吗？')){ 
	var backinfo = ajaxback('<{ofunc type=url link="/adminpage/shop/module/delgoods/datatype/json"}>',{'id':gid});
	    if(backinfo.flag == true)
	    {
		    hideop();
		  diaerror(backinfo.content); 
	     }else{
	  	    hideop();
	  	    $('#goodstr_'+gid).remove();
	  	    artsucces('删除成功'); 
	     }  
	}
}
var dialogs ;
function editgoods(gid){
		 dialogs = art.dialog.open(siteurl+'/index.php?ctrl=adminpage&action=shop&module=goodsone&gid='+gid,{height:'500px',width:'700px'},false);
	 	 dialogs.title('编辑商品'); 
}
function refreshgoods(info){
	 dialogs.close();
	 $('#goodstr_'+info.id).remove();
	 
	var htmldata = '<div class="order_list	listgoodsdet goodsdiv_'+info.typeid+'" data="'+info.id+'" id="goodstr_'+info.id+'" >';
              htmldata += ' <div class="order_goodlist">';
              htmldata += '       <div class="cd_name">';
              htmldata += '          <p class="name">'+info.name+'</p>';
              htmldata += '       </div>';
              htmldata += '      <div class="cd_price">';
              htmldata += '          <p class="cost">'+info.cost+'</p>  ';
              htmldata += '     </div>';          
			      htmldata += '      <div class="cd_order">';
              htmldata += '           <p class="good_order">'+info.good_order+'</p>   ';
              htmldata += '      </div>';
              htmldata += '       <div class="cd_caozuo">';
              htmldata += '          <span style=" background:#27a9e3; padding:8px; color:#fff;" class="curbtn" onclick="editgoods(\''+info.id+'\');">编辑</span>';
              htmldata += '            <span style=" background:#ec7501; padding:8px; color:#fff;" class="curbtn" onclick="delgoods(\''+info.id+'\');">删除</span>';
              htmldata += '      </div>';
              htmldata += '  </div> ';
              htmldata += '</div>'; 
          $('#additem').before(htmldata); 
	var allobj = $(".caidanSet").find('li');
		var typeid = 0;
		for(var i=0;i< $(allobj).length;i++){ 
		   if($(allobj).eq(i).hasClass("cur") ==  true){
		      typeid = $(allobj).eq(i).attr('data');
		    }
		}
		if(typeid != info.typeid){
			$('#goodstr_'+info.id).hide();
		}
	
 
  
}

  </script>
 	
	
	
	
	
	
	
	
	  <div id="palywave" style="display:none;"></div>
<!------以下是公共的底部部分------->
    <div class="footer">
    	<div class="foot1">
        <center>
        	<div class="db">
        	   <{if !empty($toplink)}>
	 	      <{$toplink = $toplink|unserialize}>
		  	  <{foreach from=$toplink key=myid item=items}> 
			         <a href="<{$items['typeurl']}>"><{$items['typename']}></a> | 
			    <{/foreach}>
			<{/if}> 
         
            </div></center>
            <div class="cl"></div>
        </div>
        <div class="foot2">
        	<p>@2008-2012 <{$sitename}> <{$beian}> <{$footerdata|stripslashes}></p>
        </div>
    </div> 

</body>

</html>